package com.dirk.happie.widgets;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class NavigationBarView extends View {
	private Paint mPaint = new Paint();
	private Paint sPaint = new Paint();
	private int count = 2;
	private int pos = 0;
	private int dY = 5;
	private int dX = 3;
	private int width;
	private int height = 20;
	private int radius;
	private int firstPos;

	public NavigationBarView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public NavigationBarView(Context context, int count, int pos) {
		super(context);
		this.count = count;
		this.pos = pos;
		init();
	}

	private void init() {

		mPaint.setAntiAlias(true);
		mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
		mPaint.setAlpha(100);
		mPaint.setColor(Color.WHITE);

		sPaint.setAntiAlias(true);
		sPaint.setStyle(Paint.Style.FILL_AND_STROKE);
		mPaint.setAlpha(100);
		sPaint.setColor(Color.GRAY);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		width = getWidth();
		height = getHeight();
		radius = height / 4;
		dY = height/4;
		dX = radius/4;
		firstPos = (width - count * 2 * (radius + dX)) / 2 + radius + dX;

		for (int i = 0; i < count; i++) {
			if (i != pos) {
				canvas.drawCircle(i * 2 * (radius + dX) + firstPos, radius + dY, radius, mPaint);
			} else {
				canvas.drawCircle(i * 2 * (radius + dX) + firstPos, radius + dY, radius, sPaint);
			}
		}

	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
		invalidate();
	}

	public int getPos() {
		return pos;
	}

	public void setPos(int pos) {
		this.pos = pos;
		invalidate();
	}
}
